package com.xuzz.study.io.bio;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Scanner;

public class BioClient {
    public static void main(String[] args) throws Exception
    {
        Socket socket = new Socket();
        socket.connect(new InetSocketAddress("127.0.0.1",6666));
        InputStream inputStream = socket.getInputStream();
        socket.getOutputStream().write("halo server".getBytes());


        Scanner input = new Scanner(System.in);
        String val = null;       // 记录输入度的字符串
        do{
            System.out.print("请输入：");
            val = input.next();       // 等待输入值
            System.out.println("您输入的是："+val);
            socket.getOutputStream().write(val.getBytes());
        }while(!val.equals("#"));   // 如果输入的值不版是#就继续输入
        System.out.println("你输入了\"#\"，程序已经退出！");
        input.close(); // 关闭资源
        socket.close();
    }
}
